package com.oscarmovie.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oscarmovie.model.Company;

public class CompanyDaoImpl extends HibernateDaoSupport implements CompanyDao {

	public void save(Company company) {
		getSession().saveOrUpdate(company);
	}

	public Company load(int id) {
		Company company = (Company)getSession().load(Company.class, id);
		return company;
	}
	
	
	public List<Company> loadAll() {
		Query query = getSession().createQuery("from Company ");
		query.setCacheable(true);
		List<Company> list = (List<Company>)query.list();
		return list;
	}
	
}
